package com.reran.demo;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.LockSupport;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @description:
 * @author: WangSiTeng
 * @date: 2021/11/27
 */
public class ThreadDemo2 {


    static class RunnableDemo implements Runnable {
        @Override
        public void run() {
            synchronized (this) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName());
            }
        }
    }


    public static void main(String[] args) throws InterruptedException {


        Thread thread = new Thread(new RunnableDemo());
        thread.setDaemon(true);
        thread.start();

        LockSupport.park();
        LockSupport.unpark(thread);

        System.out.println("Exiting main Thread: " + Thread.currentThread().getName());

    }
}
